<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>机械表</title>
    <style>
        .clock {
            width: 600px;
            height: 600px;
            margin: 50px auto;
            background: url(images/clock.jpg) no-repeat;
            position: relative;
        }

        .clock div {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: url(images/hour.png) no-repeat center center;
        }

        #m {
            background-image: url(images/minute.png);
        }

        #s {
            background-image: url(images/second.png);
        }
    </style>
</head>
<body>
<div class="clock">
    <div id="h"></div>
    <div id="m"></div>
    <div id="s"></div>
</div>
<script>
    var hh = document.getElementById("h");//时针
    var mm = document.getElementById("m");//分针
    var ss = document.getElementById("s");//秒针
    function clock() {
        var d = new Date();
        var ms = d.getMilliseconds();
        var s = d.getSeconds() + ms / 1000;//秒钟
        ss.style.transform = "rotate(" + (s * 6) + "deg)";
        var m = d.getMinutes() + s / 60;//分钟
        mm.style.transform = "rotate(" + (m * 6) + "deg)";
        var h = d.getHours() + m / 60;//小时
        hh.style.transform = "rotate(" + (h * 30) + "deg)";
    }
    //clock();
    setInterval(clock, 100);


</script>
</body>
</html>